﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace TreasureBox
{
    public partial class TreasureBox : Form
    {

        public TreasureBox()
        {
            InitializeComponent();
        }

        private void ShowNewForm(object sender, EventArgs e)
        {
            RegGmails reg = new RegGmails();
            reg.Width = this.Width;
            reg.Height = this.Height;
            reg.MdiParent = this;
            reg.Show();
        }

        private void CascadeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.Cascade);
        }

        private void TileVerticalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileVertical);
        }

        private void TileHorizontalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.TileHorizontal);
        }

        private void ArrangeIconsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            LayoutMdi(MdiLayout.ArrangeIcons);
        }

        private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e)
        {
            foreach (Form childForm in MdiChildren)
            {
                childForm.Close();
            }
        }

        private void SendMailsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SendMails sendMails = new SendMails();
            ShowForm(sendMails);
        }

        private void RegisterGmailsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            RegGmails reg = new RegGmails();
            ShowForm(reg);
        }


        private void GmailListToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Gmails gmails = new Gmails();
            ShowForm(gmails);
        }

        private void ShangHaiStockToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string IconImage = "money.ico";
            string Title = "上海证券交易所_公告及交易提示";
            string Url = "http://www.sse.com.cn/sseportal/ps/zhs/ggts/ssgsggqw_full.shtml";
            ShowForm(IconImage, Title, Url);

        }

        private void ShenZhenStockToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string IconImage = "money.ico";
            string Title = "深圳证券交易所";
            string Url = "http://disclosure.szse.cn/m/drgg.htm";
            ShowForm(IconImage, Title, Url);
        }

        private void SinaMsgToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string IconImage = "money.ico";
            string Title = "交易提示_财经_新浪网";
            string Url = "http://finance.sina.com.cn/focus/jyts/index.shtml";
            ShowForm(IconImage, Title, Url);
        }
        private void SearchStockToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string IconImage = "money.ico";
            string Title = "股票首页_新浪财经_新浪网";
            string Url = "http://finance.sina.com.cn/stock";
            ShowForm(IconImage, Title, Url);
        }
        private void SelectBySelfToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Stock stock = new Stock();
            stock.Width = this.Width;
            stock.Height = this.Height;
            stock.MdiParent = this;
            stock.Show();
        }

        private void ShowForm(string IconImage, string Title, string Url)
        {
            CloseAllChildForms();
            Form ShangHaiStockForm = new Form();
            ShangHaiStockForm.MdiParent = this;
            Icon icon = new Icon(IconImage);
            ShangHaiStockForm.Icon = icon;
            ShangHaiStockForm.Text = Title;
            ShangHaiStockForm.WindowState = FormWindowState.Maximized;
            ShangHaiStockForm.Width = this.Width;
            ShangHaiStockForm.Height = this.Height;
            WebBrowser browser = new WebBrowser();
            browser.Dock = DockStyle.Fill;
            ShangHaiStockForm.Controls.Add(browser);
            browser.Navigate(Url);
            ShangHaiStockForm.Show();
        }
        private void CloseAllChildForms()
        {
            foreach (Form childForm in MdiChildren)
            {
                childForm.Close();
            }
        }
        private void AboutUsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AboutUs aboutus = new AboutUs();
            ShowForm(aboutus);

        }
        private void ShowForm(Form form)
        {
            form.Width = this.Width;
            form.Height = this.Height;
            form.MdiParent = this;
            form.Show();
        }

        private void TreasureBox_Load(object sender, EventArgs e)
        {

        }





    }
}
